import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import '../../../app_files.dart';
import 'action.dart';
import 'state.dart';

Widget buildView(
    SearchAccountViewState state, Dispatch dispatch, ViewService viewService) {
  return Scaffold(
    appBar: myAppBar(viewService.context, title: '户号查询'),
    backgroundColor: Colors.white,
    body: GestureDetector(
      behavior: HitTestBehavior.translucent,
      child: Column(
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(left: 45, right: 45, top: 40),
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xffEAEAEA), width: 0.5),
              borderRadius: BorderRadius.all(Radius.circular(4)),
              color: ThemeConfig.separeColor,
            ),
            height: 50,
            child: Row(
              children: [
                Padding(
                  padding: EdgeInsets.symmetric(horizontal: 14),
                  child: Image.asset('images/ic_psword.png'),
                ),
                Container(
                  height: 24,
                  width: 0.5,
                  color: Color(0xffc1c1c1),
                ),
                Expanded(
                  child: Container(
                    padding: EdgeInsets.only(left: 14),
                    child: TextField(
                      style: TextStyle(
                          fontSize: 14, color: ThemeConfig.blackColor),
                      decoration: InputDecoration(
                        border: InputBorder.none,
                        hintText: "请输入户主姓名",
                        hintStyle: TextStyle(fontSize: 14),
                        contentPadding: EdgeInsets.only(),
                      ),
                      controller: state.nameController,
//                onChanged: (String str) {
//                  if (str.length > ThemeConfig.passwordTextLength)
//                    state.passwordController.text = str.substring(
//                        0, ThemeConfig.passwordTextLength);
//                },
                    ),
                  ),
                ),
              ],
            ),
          ),

          Container(
            margin: EdgeInsets.only(left: 45, right: 45, top: 20),
            decoration: BoxDecoration(
              border: Border.all(color: Color(0xffEAEAEA), width: 0.5),
              borderRadius: BorderRadius.all(Radius.circular(4)),
              color: ThemeConfig.separeColor,
            ),
            height: 50,
            child: Row(
              children: [
                Padding(
                  padding: EdgeInsets.symmetric(horizontal: 14),
                  child: Image.asset('images/ic_phone.png'),
                ),
                Container(
                  height: 24,
                  width: 0.5,
                  color: Color(0xffc1c1c1),
                ),
                Expanded(
                  child: Container(
                    padding: EdgeInsets.only(left: 14),
                    child: TextField(
                      style: TextStyle(
                          fontSize: 14, color: ThemeConfig.blackColor),
                      keyboardType: TextInputType.phone,
                      decoration: InputDecoration(
                        border: InputBorder.none,
                        hintText: "请输入手机号码",
                        hintStyle: TextStyle(fontSize: 14),
                        contentPadding: EdgeInsets.only(),
                      ),
                      controller: state.phoneController,
//                onChanged: (String str) {
//                  if (str.length > ThemeConfig.passwordTextLength)
//                    state.passwordController.text = str.substring(
//                        0, ThemeConfig.passwordTextLength);
//                },
                    ),
                  ),
                ),
              ],
            ),
          ),

//          Container(
//            margin: EdgeInsets.only(left: 45, right: 45, top: 20),
//            decoration: BoxDecoration(
//              border: Border.all(color: Color(0xffEAEAEA), width: 0.5),
//              borderRadius: BorderRadius.all(Radius.circular(4)),
//              color: ThemeConfig.separeColor,
//            ),
//            height: 50,
//            child: Row(
//              children: [
//                Padding(
//                  padding: EdgeInsets.symmetric(horizontal: 14),
//                  child: Image.asset('images/ic_gasNo.png'),
//                ),
//                Container(
//                  height: 24,
//                  width: 0.5,
//                  color: Color(0xffc1c1c1),
//                ),
//                Expanded(
//                  child: Container(
//                    padding: EdgeInsets.only(left: 14),
//                    child: TextField(
//                      style: TextStyle(
//                          fontSize: 14, color: ThemeConfig.blackColor),
//                      decoration: InputDecoration(
//                        border: InputBorder.none,
//                        hintText: "请输入燃气表号",
//                        hintStyle: TextStyle(fontSize: 14),
//                        contentPadding: EdgeInsets.only(),
//                      ),
//                      controller: state.accountController,
////                onChanged: (String str) {
////                  if (str.length > ThemeConfig.passwordTextLength)
////                    state.passwordController.text = str.substring(
////                        0, ThemeConfig.passwordTextLength);
////                },
//                    ),
//                  ),
//                ),
//              ],
//            ),
//          ),

          Container(
            margin: EdgeInsets.only(left: 45, right: 45, top: 40),
            height: 50,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(4)),
              color: ThemeConfig.mainColor,
            ),
            child: InkWell(
              child: Center(
                child: Text(
                  '查询',
                  style: TextThemeConfig.Font16WithWhite,
                ),
              ),
              onTap: () => dispatch(SearchAccountViewActionCreator.onSubmit()),
            ),
          ),
        ],
      ),
      onTap: () => FocusScope.of(viewService.context).requestFocus(FocusNode()),
    ),
  );
}
